<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="120">
            <Row class="query-form">
                <Col span="8">
                    <FormItem label="企业名称：" prop="companyId">
                        <div>
                            <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName' :orgTree="true"
                                          :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
                        </div>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label='所属行业：'>
                        <Select v-model='dataToQuery.industry' placeholder="请选择所属行业" class='query-form-el' clearable>
                            <Option v-for="item in dictMap.industrys" :value="item.codingCodeId"
                                    :key="item.codingCodeId">{{item.codingName }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <!--<Col span="8">-->
                <!--<FormItem label='考核编号：'>-->
                <!--<Input class='query-form-el' type='text' v-model='dataToQuery.unitNo'></Input>-->
                <!--</FormItem>-->
                <!--</Col>-->
                <Col span="8" v-if="!switchFlag">
                    <!--<Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>-->
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
                <Col span="8" v-else>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">

                <Col span="8">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
                    <Button size="large" class="ivu-btn-add" icon="md-download" @click="downloadDescriptionExcel">导出模板</Button>
                    <Button size="large" class="ivu-btn-add" icon="md-cloud-upload" @click="beachUpload">批量导入</Button>
                    <download-button :api="exportUrl" :queryForm="dataToQuery" />
                    <!-- <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="exportList">导出</Button> -->
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
               :loading='pageStatus.loading' @on-expand="onExpand"
               border :columns="columns1" :data="dataTable">
        </Table>
        <!--分页-->
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
                <!-- <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange1" @on-page-size-change="pageSizeChange1" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator /> -->
            </Col>
        </Row>
        <!--新增、修改、详情-->
        <Modal :title="mode == 'view' ?'企业环保设施情况统计表详情':'企业环保设施情况统计表'" :transfer=false :mask-closable="false"
               v-model="dialogShow" v-if="dataToView && dialogShow" :width=850 class-name='limit-height-dialog'>
            <Row>
                <Col span="24">
                    <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':'modal-form'"
                          :show-message="false" :model="dataToView" :rules="mode === 'view'?{} :ruleCustom"
                          :label-position="mode === 'view'?'right':'top'" :label-width="mode === 'view'?140:null">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='企业名称：' prop='companyId'>
                                    <div v-if="mode === 'view'">{{dataToView.companyName}}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写企业名称" disabled type='text' v-model='dataToView.companyName'></Input>
                                    <!--<cascader-dom v-else ref='orgCascader' @setOrgInfo='setCompanyId' @setOrgname="setCompanyName" :orgTree="true" :currentOrgId="dataToView.companyId"-->
                                                  <!--:setCurrentName="{label:dataToView.companyName,value:dataToView.companyId}"></cascader-dom>-->
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='所在街乡镇：' prop='streetTownship'>
                                    <div v-if="mode === 'view'">{{ dataToView.streetTownship }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写所在街乡镇" type='text' maxlength="100" show-word-limit v-model='dataToView.streetTownship'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='企业地址：' prop='address'>
                                    <div v-if="mode === 'view'">{{ dataToView.address }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写企业地址" type='text' maxlength="100" show-word-limit v-model='dataToView.address'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='所属行业：' prop='industry'>
                                    <div v-if="mode === 'view'">{{ dataToView.industryName }}</div>
                                    <Select  v-else v-model='dataToView.industry' placeholder="请选择企业类型" class='query-form-el'>
                                        <Option v-for="item in dictMap.industrys" :value="item.codingCodeId"
                                                :key="item.codingCodeId">{{item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row>
                            <Col span="23" class="query-form" style="margin-left: 15px">
                                <Button v-if="mode !== 'view'" class="ivu-btn-add" icon="md-add"
                                        @click="itemModel=true,itemAdd=true;detailItem={}">新增环保设施信息</Button>
                                <Table highlight-row stripe border style="margin-top:10px;margin-bottom: 10px" :max-height="350" :columns="itemColumn"
                                       :data="dataToView.items">
                                </Table>
                            </Col>
                        </Row>

                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='填报人：' prop='createUserName'>
                                    <div v-if="mode === 'view'">{{ dataToView.createUserName }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写填报人" type='text' readonly
                                           v-model='dataToView.createUserName'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='填报时间：' prop='createDate'>
                                    <div v-if="mode === 'view'">{{ renderViewDate(dataToView.createDate) }}</div>
                                    <DatePicker v-else class="query-form-el" placeholder="请选择填报时间" readonly
                                                v-model='dataToView.createDate'></DatePicker>
                                </FormItem>
                            </Col>
                        </Row>
                        <!--<Row type="flex" justify="space-around" class="code-row-bg">-->
                            <!--<Col span="11">-->
                                <!--<FormItem label='填报人手机号：' prop='mobileNumber'>-->
                                    <!--<div v-if="mode === 'view'">{{ dataToView.mobileNumber }}</div>-->
                                    <!--<Input v-else class='query-form-el' placeholder="请填写手机号" type='text' v-model='dataToView.mobileNumber'></Input>-->
                                <!--</FormItem>-->
                            <!--</Col>-->
                            <!--<Col span="11"></Col>-->
                        <!--</Row>-->
                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-save' @click="submit('dialogForm')">确定</Button>
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-cancel' @click="handleCancel">取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>

        <Modal :mask-closable="false" :transfer=false v-model="itemModel" :width=700 title="环保设施信息"
               @on-cancel="itemModel=false,detailItem={}">
            <Row>
                <Col span="24">
                    <Form ref="itemForm" :class="'modal-form'" :show-message="false" :model="detailItem" :rules="itemRuleCustom" label-position="top" >
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='环保设施名称：' prop='facility'>
                                    <div v-if="mode === 'view'">{{ detailItem.facilityName }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写环保设施名称" type='text' v-model='detailItem.facilityName'></Input>-->
                                    <Select  v-else v-model='detailItem.facility' placeholder="请选择环保设施名称" class='query-form-el'
                                             label-in-value @on-change="(val)=>{detailItem.facility=val.value,detailItem.facilityName=val.label}">
                                        <Option v-for="item in dictMap.facilitys" :value="item.codingCodeId"
                                                :key="item.codingCodeId">{{item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='对应产污设施/部位：' prop='part'>
                                    <div v-if="mode === 'view'">{{ detailItem.part }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写对应产污设施/部位" type='text' maxlength="100" show-word-limit v-model='detailItem.part'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='环保设施使用阶段：' prop='usePhase'>
                                    <div v-if="mode === 'view'">{{ detailItem.usePhaseName }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写环保设施使用阶段" type='text' v-model='detailItem.usePhase'></Input>-->
                                    <Select  v-else v-model='detailItem.usePhase' placeholder="请选择环保设施使用阶段" class='query-form-el'
                                             label-in-value @on-change="(val)=>{detailItem.usePhase=val.value,detailItem.usePhaseName=val.label}">
                                        <Option v-for="item in dictMap.usePhases" :value="item.codingCodeId"
                                                :key="item.codingCodeId">{{item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='环保设施项目合作模式：' prop='cooperativeModel'>
                                    <div v-if="mode === 'view'">{{ detailItem.cooperativeModelName }}</div>
                                    <!--<Input v-else class='query-form-el' placeholder="请填写环保设施项目合作模式" type='text' v-model='detailItem.cooperativeModel'></Input>-->
                                    <Select  v-else v-model='detailItem.cooperativeModel' placeholder="请选择环保设施项目合作模式" class='query-form-el'
                                             label-in-value @on-change="(val)=>{detailItem.cooperativeModel=val.value,detailItem.cooperativeModelName=val.label}">
                                        <Option v-for="item in dictMap.cooperativeModels" :value="item.codingCodeId"
                                                :key="item.codingCodeId">{{item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='环保设施企业名称：' prop='facilityCompanyName'>
                                    <div v-if="mode === 'view'">{{ detailItem.facilityCompanyName }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写环保设施企业名称" type='text' maxlength="100" show-word-limit v-model='detailItem.facilityCompanyName'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem label='备注：' prop='remark'>
                                    <div v-if="mode === 'view'">{{ detailItem.remark }}</div>
                                    <Input v-else class='query-form-el' placeholder="请填写备注" type='textarea'
                                           maxlength="255" show-word-limit :autosize="{minRows:2,maxRows:5}" v-model='detailItem.remark'></Input>
                                </FormItem>
                            </Col>
                        </Row>

                    </Form>
                </Col>
            </Row>
            <div slot="footer">
                <Button type="primary" class='ivu-btn-save' @click="itemSubmit('itemForm')">确定</Button>
                <Button type="primary" class='ivu-btn-cancel' @click="itemModel=false,detailItem={}">取消</Button>
                <!--<Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>-->
            </div>
        </Modal>


        <Modal :mask-closable="false" :transfer=false  v-model="model3" :width=700 title="企业环保设施情况统计表导入" @on-cancel="cancelMap">
            <Form  ref="map" :show-message="false" :model="map" :rules="mapRuleCustom" label-position="top">
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem label='企业名称：' prop='companyId'>
                            <cascader-dom ref='orgCascader1' @setOrgInfo='setCompanyId1' @setOrgname="setCompanyName1"
                                          :orgTree="true" :currentOrgId="currentUser.companyId">
                            </cascader-dom>
                        </FormItem>
                    </Col>
                </Row>
                <Row type="flex" justify="space-around" class="code-row-bg">
                    <Col span="23">
                        <FormItem  label="" prop="file">
                            <div>
                                <Upload ref="upload1"
                                        :before-upload="handleUpload "
                                        :format="['xlsx', 'xls']"
                                        accept=".xlsx, .xls"
                                        :max-size="10240"
                                        type="drag"
                                        :action="uploadUrl">
                                    <div style="padding: 10px">
                                        <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                        <p>点击将文件拖拽到这里上传</p>
                                        <span style="font-size:8px;color: #797a64">仅支持上传单个excel </span>
                                    </div>
                                </Upload>
                            </div>
                            <div v-if="fileTrue">
                                <a>{{ map.file.name }}</a>
                                <Button type="text" icon="md-trash" @click="map.file = {},fileTrue = false" style="margin-left: 5px;margin-bottom: 3px"/>
                            </div>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button type="primary" class='ivu-btn-save' :disabled="uploadDissabled" @click="submitFile('map')">确定</Button>
                <Button type="primary" class='ivu-btn-cancel' @click="cancelMap">取消</Button>
            </div>
        </Modal>

        <Modal title="导入详情" v-model="logInfoModel" :transfer=false :mask-closable="false">
            <Row type="flex" justify="space-around" class="code-row-bg">
                <Col span="23">
                    <div v-html="logInfo"></div>
                </Col>
            </Row>
            <div slot="footer">
                <Button type="primary" class='ivu-btn-cancel' @click="logInfoModel=false,logInfo=null">关闭</Button>
            </div>
        </Modal>

    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    import {sessionStorage} from '@/common/cacheUtils.js';
    import {formatDate} from '@/tools/index'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import pageCommonFunction from '@/components/pageCommonFunction.js'

    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                columns1: [
                    {type:'expand', width:30,
                        fixed: 'left',
                        _disableExpand:true,
                        render:(h,params)=>{
                            return h('Table',{
                                props: {
                                    columns: [
                                        { key:'facilityName',title: '环保设施名称',  align: 'center', minWidth: 120,  },
                                        { key:'part',title: '对应产污设施/部位',  align: 'center', minWidth: 120,  },
                                        { key:'usePhaseName',title: '环保设施使用阶段',  align: 'center', minWidth: 120,  },
                                        { key:'facilityCompanyName',title: '环保设施企业名称',  align: 'center', minWidth: 120,  },
                                        { key:'cooperativeModelName',title: '环保设施项目合作模式',  align: 'center', minWidth: 120,  },
                                        { key:'remark',title: '备注',  align: 'center', minWidth: 120,  },
                                    ],//表头
                                    data: params.row.items,//内部表格展示的数据
                                },
                            })//我这里使用的是表格，大家也可以根据自己的实际情况更换别的组件
                        }
                    },
                    {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    { key:'companyName',title: '单位名称',  align: 'center', minWidth: 120,  },
                    { key:'streetTownship',title: '所在街乡镇',  align: 'center', minWidth: 120,  },
                    { key:'address',title: '企业地址',  align: 'center', minWidth: 120,  },
                    { key:'industryName',title: '所属行业',  align: 'center', minWidth: 120,  },
                    { key:'belongOrgName',title: '所属二级集团',  align: 'center', minWidth: 120,  },
                    { key:'createUserName',minWidth: 100,title: '填报人',  align: 'center' },
                    // { key:'mobileNumber',title: '填报人手机号',  align: 'center', minWidth: 120,  },
                    this.getActionColumns()
                ],
                ruleCustom: {
                    companyId: [ { required: true, message: '请填写单位名称', trigger: 'change',}],
                    streetTownship: [ { required: true, message: '请填写所在街乡镇', trigger: 'change',}],
                    address: [ { required: true, message: '请填写企业地址', trigger: 'change',}],
                    industry: [ { required: true, message: '请填写所属行业', trigger: 'change',}],
                    mobileNumber: [ {
                        validator: (rule, value, callback) => {
                            if(!(/^1[3456789]\d{9}$/.test(this.dataToView.mobileNumber))){
                                callback(' ');
                                // this.$Message.error("请填写有效的的手机号")
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'blur'
                    }],
                },
                tableHeight: 10,
                dictMap:{},
                detailItem:{},
                itemModel:false,
                itemAdd:false,
                columns2: [
                    {title: '序号', width: 70, align: 'center', render: this.indexColumnsRender},
                    { key:'facilityName',title: '环保设施名称',  align: 'center', minWidth: 120,  },
                    { key:'part',title: '对应产污设施/部位',  align: 'center', minWidth: 120,  },
                    { key:'usePhaseName',title: '环保设施使用阶段',  align: 'center', minWidth: 120,  },
                    { key:'facilityCompanyName',title: '环保设施企业名称',  align: 'center', minWidth: 120,  },
                    { key:'cooperativeModelName',title: '环保设施项目合作模式',  align: 'center', minWidth: 120,  },
                    { key:'remark',title: '备注',  align: 'center', minWidth: 120,  },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 110,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '13px',},
                                    on: {
                                        click: () => {
                                            this.detailItem = {...params.row}
                                            this.itemModel = true
                                            this.itemAdd = false
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {props: {type: 'vertical'}}, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '13px',color: 'red'},
                                    on: {
                                        click: () => {
                                            this.dataToView.items.splice(params.index,1)
                                        }
                                    }
                                }, '删除'),
                            ])
                        }
                    }
                ],
                itemRuleCustom: {
                    facility: [ { required: true, message: '请填写环保设施名称', trigger: 'change',}],
                    part: [ { required: true, message: '请填写对应产污设施/部位', trigger: 'change',}],
                    usePhase: [ { required: true, message: '请填写环保设施使用阶段', trigger: 'change',}],
                    facilityCompanyName: [ { required: true, message: '请填写环保设施企业名称', trigger: 'change',}],
                    cooperativeModel: [ { required: true, message: '请填写环保设施项目合作模式', trigger: 'change',}],
                    // remark: [ { required: true, message: '请填写备注', trigger: 'change',}],
                },
                // api
                exportUrl: Api.exportFacilitiesStatistics,
                queryUrl: Api.queryFacilitiesStatistics,
                deleteUrl: Api.deleteFacilitiesStatistics,
                updateUrl: Api.updateFacilitiesStatistics,
                saveUrl: Api.saveFacilitiesStatistics,
                uploadUrl: Api.uploadFacilitiesStatistics,
                buttonLoading: false,

                fileTrue: false,
                model3:false,
                map:{},
                mapRuleCustom: {
                    companyId: [{required: true, message: ' ', trigger: 'change'}],
                    file: [{
                        validator: (rule, value, callback) => {
                            if (this.map.file) {
                                callback()
                            } else {
                                callback(' ')
                            }
                        },
                        required: true,
                        message: ' ',
                        trigger: 'change'
                    }]
                },
                uploadDissabled: false,
                logInfoModel:false,
                logInfo:null
            }
        },
        computed: {
            itemColumn() {
                const columns = [...this.columns2];
                const columns1 = []
                columns.forEach(item => {
                    if (this.mode !== 'view') {
                        columns1.push(item)
                    } else {
                        if (item.key !== 'action') {
                            columns1.push(item)
                        }
                    }
                })
                return columns1
            },
        },
        async mounted() {
            this.setTableHeight();
            this.$http.get(Api.queryDictBycode+"env-00025,env-00026,env-00027,env-00028",{}).then((res)=>{
                this.dictMap = {
                    'industrys': res.data.data['env-00025'],
                    'facilitys': res.data.data['env-00026'],
                    'usePhases': res.data.data['env-00027'],
                    'cooperativeModels': res.data.data['env-00028']
                }
            }).catch(e => {this.$Message.error("数据字典获取失败")});
            this.query();
        },
        methods: {
            ...pageCommonFunction,
            submitFile(map){
                this.$refs[map].validate((valid) => {
                    if (valid) {
                        this.uploadDissabled = true
                        let formData = new FormData();
                        formData.append("file", this.map.file);
                        formData.append("companyId", this.map.companyId);
                        formData.append("createUserId", this.currentUser.userId);
                        formData.append("createOrgId", this.currentUser.orgInfo.orgId);
                        this.$http.post(this.uploadUrl, formData).then((res) => {
                            this.uploadDissabled = false
                            if (res.data.status == "200") {
                                this.logInfoModel = true
                                this.logInfo = res.data.data
                                // this.$Modal.warning({
                                //     title: '批量导入提示',
                                //     content: JSON.stringify(res.data.data)
                                // });
                                this.query()
                            } else {
                                this.$Message.error(res.data.msg);
                            }
                            this.map={}
                            this.fileTrue = false
                            this.model3=false
                        }).catch(e => {
                            console.log(e);
                            this.model3=false
                            this.map={}
                            this.uploadDissabled = false
                            this.$Message.error("导入失败！请检查导入文档的格式是否正确");
                        })
                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })

            },
            handleUpload (file) {
                this.map.file = file;
                this.fileTrue = true
                return false;
            },
            cancelMap() {
                this.model3 = false
                this.fileTrue = false
                this.map ={}
                this.$refs.orgCascader1.resetCurrentOrg();
            },
            beachUpload(){
                this.fileTrue = false
                this.map ={}
                this.model3 = true
                this.$refs.orgCascader1.resetCurrentOrg();
            },
        downloadDescriptionExcel() {
                this.$http.get(this.uploadUrl+'/model', {
                    responseType: 'blob'      //告诉服务器我们需要的响应格式
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = "企业环保设施情况统计表模板.xlsx" //标题
                    aLink.click()
                    document.body.appendChild(aLink)
                })
            },
            setCompanyId1(data) {
                if (data && data instanceof Array && data.length > 0) {
                    this.$set(this.map, 'companyId', data[data.length - 1])
                }
            },
            setCompanyName1(data) {
                if (data) {
                    this.map.companyName = data;
                }
            },

            itemSubmit(name){
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Modal.confirm({
                            title: '提示',
                            content: '<p>是否要提交？</p>',
                            onOk: () => {
                                let _this = this
                                _this.dataToView.items.splice()
                                if (_this.itemAdd) {
                                    _this.dataToView.items.push(_this.detailItem)
                                } else {
                                    _this.dataToView.items[_this.detailItem._index]= _this.detailItem
                                }
                                _this.itemModel = false
                            },
                            onCancel: () => {}
                        })
                    }else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },

            deleteData(params) {
                this.deleteDateAjax(params);
            },
            exportList() {
                this.exportFormSubmit();
            },
            query() {

                this.queryAjax();
            },
            submit(name) {
                if (this.dataToView.items.length < 1) {
                    this.$Message.warning('环保设施信息至少填报一条');
                } else {
                    this.submitAjax(name);
                }
            },
            createEmptyDataToAdd() {
                return {
                    areas: 0,
                    id: this.get_uuid(),
                    idFiles: [],
                    items: [],
                }
            },
            async afterDataToViewInit() {
                // await this.getFiles1('id', 'examSelect');
            },

        }
    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
</style>
